//
//  JIUViewController.m
//  UI20_豆瓣电影storyBoard
//
//  Created by 王阳阳 on 16/1/4.
//  Copyright © 2016年 www.lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "JIUViewController.h"
#import "jiuCollectionViewCell.h"
#import "NetWorkHandler.h"
#import "movie.h"
#import "UIImageView+WebCache.h"
@interface JIUViewController () <UICollectionViewDataSource, UICollectionViewDelegate>
@property (weak, nonatomic) IBOutlet UICollectionView *celltion;
@property (nonatomic, strong)NSMutableArray *DataArr;
@end

@implementation JIUViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBarHidden = NO;

    
    
    
    [self data];
}
    - (void)data
    {
        NSString *path = @"http://project.lanou3g.com/teacher/yihuiyun/lanouproject/movielist.php";
        
        [NetWorkHandler GETWithURL:path completion:^(id result) {
            NSArray *arr = result[@"result"];
            
            self.DataArr = [movie modelHandlerWithArray:arr];
            [self.celltion reloadData];
        }];
    }
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return _DataArr.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    jiuCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    movie * mm = _DataArr[indexPath.row];
    cell.name.text = mm.movieName;
    [cell.image sd_setImageWithURL:[NSURL URLWithString:mm.pic_url]];
    return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
